﻿using Newtonsoft.Json;

namespace express.compiler;

public class SyntaxNode
{
    private List<SyntaxNode> childNodes = new List<SyntaxNode>();

    private String value;
    private SyntaxNodeType type;
    
    public SyntaxNode(SyntaxNodeType type) {
        this.type = type;
    }

    public SyntaxNode(SyntaxNodeType type, String value) {
        this.type = type;
        this.value = value;
    }
    
    public void addChild(SyntaxNode node) {
        childNodes.Add(node);
    }
    
    public string Value
    {
        get { return value;}
        set { this.value = value; }
    }

    public SyntaxNodeType Type
    {
        get { return this.type; }
        set { this.type = value; }
    }

    public List<SyntaxNode> ChildNodes
    {
        get { return this.childNodes; }
    }

    public override string ToString()
    {
        return JsonConvert.SerializeObject(this,Formatting.Indented);
    }
}